#标准输入$stdin/输出$stdout/错误输出$stderr
3.times do |i|
    $stdout.puts "#{Random.rand}"
    $stderr.puts "输出#{i+1}次"
end

# ruby out.rb > log.txt